package com.maiji.cloud.controller.shopingmall;

import com.maiji.cloud.controller.BaseController;
import com.maiji.cloud.entities.login.Label;
import com.maiji.cloud.entities.shopingmall.GoodsComment;
import com.maiji.cloud.request.BaseDataReqDto;
import com.maiji.cloud.request.shopingmall.GoodsCommentFindAllReqData;
import com.maiji.cloud.request.shopingmall.FindByIdReqDto;
import com.maiji.cloud.request.shopingmall.GoodsCommentReqData;
import com.maiji.cloud.response.BaseDataResDto;
import com.maiji.cloud.response.BaseMetaResDto;
import com.maiji.cloud.response.BaseResDto;
import com.maiji.cloud.response.login.LabelResData;
import com.maiji.cloud.utils.Unlogin;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController
@RequestMapping("/goodsComment")
@Api(tags = {"商品评论模块"})
public class GoodsCommentController extends BaseController {

    /**
     *  获取商品评论列表
     * @param baseDataReqDto
     * @return
     */
    @Unlogin
    @ApiOperation(value = "获取商品评论列表")
    @PostMapping("/findAllGoodsComment")
    public BaseMetaResDto<List<GoodsComment>> findAllGoodsComment (@RequestBody BaseDataReqDto<GoodsCommentFindAllReqData> baseDataReqDto,
                                                                   @RequestHeader("maijiToken") String token) {
        return postForObjectWithToken(token,REST_URL_SHOPINGMALL + "/goodsComment/findAllGoodsComment", baseDataReqDto, BaseMetaResDto.class);
    }

    /**
     *  查看商品评论详情
     * @param baseDataReqDto
     * @return
     */
    @PostMapping("findGoodsCommentById")
    @ApiOperation(value = "查看商品评论详情")
    public BaseMetaResDto<GoodsComment> findGoodsCommentById(@RequestBody BaseDataReqDto<String> baseDataReqDto,
                                                           @RequestHeader("maijiToken") String token) {
    	return postForObjectWithToken(token, REST_URL_SHOPINGMALL + "/goodsComment/findGoodsCommentById", baseDataReqDto, BaseMetaResDto.class);
    }

    /**
     *  商品评论的点赞或取消点赞
     * @param findByIdReqDto
     * @param token
     * @return
     */
    @PostMapping("thumbsUpGoodsCommentById")
    @ApiOperation(value = "商品评论的点赞或取消点赞")
    public BaseResDto thumbsUpGoodsCommentById(@RequestBody FindByIdReqDto findByIdReqDto, @RequestHeader("maijiToken") String token) {
    	return postForObjectWithToken(token, REST_URL_SHOPINGMALL + "/goodsComment/thumbsUpGoodsCommentById", findByIdReqDto, BaseResDto.class);
    }

    /**
     *  获取商品评论的列表标签[]
     * @return
     */
    @ApiOperation(value = "获取商品评论的列表标签[]")
    @PostMapping("findAllGoodsCommentListLabels")
    public BaseDataResDto<List<LabelResData>> findAllGoodsCommentListLabels (@RequestHeader("maijiToken") String token) {
        return restTemplate.postForObject(REST_URL_APPLOGIN + "/common/findAllLabelsBySource",
                new BaseDataReqDto<Label>().setData(new Label().setSource("商品评论").setListShow(1)), BaseDataResDto.class);
    }

    /**
     *  获取商品评论的普通标签[]
     * @return
     */
    @ApiOperation(value = "获取商品评论的普通标签[]")
    @PostMapping("findAllGoodsCommentLabels")
    public BaseDataResDto<List<LabelResData>> findAllGoodsCommentLabels (@RequestHeader("maijiToken") String token) {
        return restTemplate.postForObject(REST_URL_APPLOGIN + "/common/findAllLabelsBySource",
                new BaseDataReqDto<Label>().setData(new Label().setSource("商品评论").setListShow(0)), BaseDataResDto.class);
    }

    /**
     *  发表商品评论
     * @param baseDataReqDto
     * @param token
     * @return
     */
    @PostMapping("publishGoodsComment")
    @ApiOperation(value = "发表商品评论")
    public BaseResDto publishGoodsComment(@RequestBody BaseDataReqDto<GoodsCommentReqData> baseDataReqDto,
                                          @RequestHeader("maijiToken") String token) {
        return postForObjectWithToken(token, REST_URL_SHOPINGMALL + "/goodsComment/publishGoodsComment", baseDataReqDto, BaseResDto.class);
    }

    /**
     *  批量发表商品评论
     * @param baseDataReqDto
     * @param token
     * @return
     */
    @PostMapping("publishGoodsCommentBatch")
    @ApiOperation(value = "批量发表商品评论")
    public BaseResDto publishGoodsCommentBatch(@RequestBody BaseDataReqDto<List<GoodsCommentReqData>> baseDataReqDto,
                                          @RequestHeader("maijiToken") String token) {
        return postForObjectWithToken(token, REST_URL_SHOPINGMALL + "/goodsComment/publishGoodsCommentBatch", baseDataReqDto, BaseResDto.class);
    }

    /**
     *  用户回复商家
     * @param baseDataReqDto
     * @return
     */
    @PostMapping("replyGoodsComment")
    @ApiOperation(value = "用户回复商家")
    public BaseResDto replyGoodsComment(@RequestBody BaseDataReqDto<GoodsCommentFindAllReqData> baseDataReqDto,
                                          @RequestHeader("maijiToken") String token) {
        return postForObjectWithToken(token,REST_URL_SHOPINGMALL + "/goodsComment/replyGoodsComment", baseDataReqDto, BaseResDto.class);
    }

}
